{extend name='public/base'}
{block name='content'}
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        {$item['item1']}
        <small>{$item['item2']}</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> {$item['item1']}</a></li>
        <li class="active">{$item['item2']}</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="row" >
        <div class="col-xs-12">
            <!-- /.box -->
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">列表</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table class="layui-hide"  id='test' lay-filter="test"></table>
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container">
                            <button class="layui-btn layui-btn-sm" lay-event="addBanner">新增标识库</button>
                            <button class="layui-btn layui-btn-sm" lay-event="batchHandler">批量删除</button>
                        </div>
                    </script>
                    <script type="text/html" id="indexTpl">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-xs" onclick="lotus_show('编辑标识库','edit_library.html?id={{d.id}}',700,500)">编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="w_tableDel('{{d.id}}', 'deleteRow')">删除</a>
                    </script>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</section>
<!-- /.content -->
{/block}


{block name='script'}
<script>
    //增加表格数据
    $(function (){
        layui.use('table', function() {
            var table = layui.table
            cols = [
                {type: 'checkbox',width:50}
                ,{field:'id',title: '序号',toolbar: '#indexTpl',width:80}
                ,{field:'name', title:'标识库名'}
                ,{field:'label_library_description', title:'标识库描述'}
                ,{title:'操作', toolbar: '#barDemo'}
            ]
            w_layuiTable('#test','get_table_data',cols,'#toolbarDemo');

            table.on('toolbar(test)', function(obj){
              var checkStatus = table.checkStatus(obj.config.id);
              switch(obj.event){
                  case 'addBanner':
                      lotus_show('新增标识库','add_library',700,500)
                      break;
                  case 'batchHandler':
                      var data = checkStatus.data;
                      res = [];
                      if(data.length <= 0 ){
                          layer.msg('至少选择一项');
                          return false;
                      }
                      for(var i=0;i<data.length;i++){    //循环筛选出id
                          res.push(data[i].id);
                      }
                      layer.confirm('确定批量删除图标吗', function(index){
                          $.ajax({
                              url: 'bachDel',
                              type: 'post',
                              dataType: 'json',
                              data: {id:res},
                          }).done(function(data){
                              //回调提示
                              if(data.code==0){
                                  layer.msg(data.msg,{icon:2,time:1000});
                              }else{
                                  layer.msg(data.msg,{icon:1,time:1500},function(){
                                      parent.location.reload();
                                  });
                              }
                          })
                      })
                      break;
              }
          })
        })
    })
</script>
{/block}